﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartProduction.Domain;
using SmartProduction.ErrorCode;
using SmartProduction.Read.API.Application.Commands.BomCommand;

namespace SmartProduction.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BomController : ControllerBase
    {

        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator">中介者</param>
        public BomController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 处理Bom显示
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">重置</param>
        /// <returns>返回集合</returns>
        [HttpGet]
        public async Task<APIResult<APIPaing<Bom>>> GetBom([FromQuery]BomQueryCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 处理工序列表显示
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">重置</param>
        /// <returns>返回集合</returns>
        [HttpGet]
        public async Task<APIResult<APIPaing<ProcessInfo>>> GetProc([FromQuery] ProcessInfoQueryCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 处理工序列表显示
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">重置</param>
        /// <returns>返回集合</returns>
        [HttpGet]
        public  Task<APIResult<List<OperationRecord>>> GetOperation([FromQuery] OperationRecordQueryCommand request, CancellationToken cancellationToken)
        {
            return  mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 处理BOM配件
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">重置</param>
        /// <returns>返回集合</returns>
        [HttpGet]
        public Task<APIResult<List<BomParts>>> GetBomParts([FromQuery] BomPartsQueryCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 处理BOM配件
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">重置</param>
        /// <returns>返回集合</returns>
        [HttpGet]
        public Task<APIResult<List<MaterListq>>> GetMateria([FromQuery] MaterialListCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request, cancellationToken);
        }
    }
}
